package org.support.small.mallms.model;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Ret<T> {
    private boolean success;
    private T data;
    private String msg;
    private LocalDateTime timestamp = LocalDateTime.now();

    public static <T> Ret<T> ok(T data) {
        Ret<T> ret = ok();
        ret.setData(data);
        return ret;
    }

    public static <T> Ret<T> ok() {
        Ret<T> ret = new Ret<>();
        ret.setSuccess(true);
        return ret;
    }

    public static <T> Ret<T> fail(String msg) {
        Ret<T> ret = new Ret<>();
        ret.setSuccess(false);
        ret.setMsg(msg);
        return ret;
    }
}
